﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using Bitis_KeToanThue_Pro_DungChung.Common;

namespace Bitis_KeToanThue_Pro_QuanTri.AccessDatabase
{
   public class DanhMucChuongTrinh
    {
        AccessData ac = new AccessData(1);
        public int sua(int ID,string tenchuongtrinh ,string DienGiai,int nhomct,string duongdan)
        {
            SqlParameter[] arrPara = new SqlParameter[6];
            arrPara[0] = new SqlParameter("@ID", SqlDbType.Int);
            arrPara[0].Value = ID;
            arrPara[1] = new SqlParameter("@TenChuongTrinh", SqlDbType.NVarChar);
            arrPara[1].Value = tenchuongtrinh;
            arrPara[2] = new SqlParameter("@DienGiai", SqlDbType.NVarChar);
            arrPara[2].Value = DienGiai;
            arrPara[3] = new SqlParameter("@NhomCT", SqlDbType.Int);
            arrPara[3].Value =nhomct;
            arrPara[4] = new SqlParameter("@Hinh", SqlDbType.Image);
            arrPara[4].Value = ClassXuLyChung.ConvertImageToByte(duongdan);
            arrPara[5] = new SqlParameter("@DuongDan", SqlDbType.NVarChar);
            arrPara[5].Value = duongdan;
            DataTable dt = ac.ftblDocDuLieuSP("thuan_qtdanhmucchuongtrinhsua", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int xoa(int ID)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@ID", SqlDbType.Int);
            arrPara[0].Value = ID;

            DataTable dt = ac.ftblDocDuLieuSP("thuan_qtdanhmucchuongtrinhxoa", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int them(string tenchuongtrinh,string diengiai,int nhomct,string duongdan)
        {
            SqlParameter[] arrPara = new SqlParameter[4];
            arrPara[0] = new SqlParameter("@TenChuongTrinh", SqlDbType.NVarChar);
            arrPara[0].Value = tenchuongtrinh;
            arrPara[1] = new SqlParameter("@DienGiai", SqlDbType.NVarChar);
            arrPara[1].Value = diengiai;
            arrPara[2] = new SqlParameter("@NhomCT", SqlDbType.Int);
            arrPara[2].Value = nhomct;
            arrPara[3] = new SqlParameter("@Hinh", SqlDbType.Image);
            arrPara[3].Value = ClassXuLyChung.ConvertImageToByte(duongdan);
            DataTable dt = ac.ftblDocDuLieuSP("thuan_qtdanhmucchuongtrinhthem", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public DataTable loaddulieubyid(int id)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@ID", SqlDbType.Int);
            arrPara[0].Value =id;

            return ac.ftblDocDuLieuSP("thuan_qtdanhmucchuongtrinhloadbyid", arrPara);

        }
        public DataTable loadcombonhomchuongtrinh()
        {

            return ac.ftblDocDuLieuSP("thuan_qtdanhmucchuongtrinhloadcombonhom", null);
        }
        public DataTable loadgird()
        {

            return ac.ftblDocDuLieuSP("thuan_qtdanhmucchuongtrinhload", null);
        }
    }
}
